#include "stdafx.h"
#include "math.h"
#include "BSpline.h"
 
int _tmain(int argc, _TCHAR* argv[])
{
	int num=8;
	double x[8]={9.59,60.81,105.57,161.59,120.5,100.1,50.0,10.0};
	double y[8]={61.97,107.13,56.56,105.27,120.5,150.0,110.0,180.0};
 
	CPosition *testpt=new CPosition[num];
	for(int i=0;i<num;i++) testpt[i]=CPosition(x[i],y[i]);
 
	int *Intnum=new int[num-1]; 
	for(int i=0;i<num-1;i++){
		Intnum[i]=10;                 //  每一个样条曲线内插入10个点
	}
 
	int num2=num;
	CBSpline bspline;
	bspline.TwoOrderBSplineInterpolatePt(testpt,num2,Intnum);        //  二次B样条曲线
	//bspline.ThreeOrderBSplineInterpolatePt(testpt,num2,Intnum);    //  三次B样条曲线
	delete Intnum;
 
 
	FILE *fp_m_x = fopen("Bspline_test_x.txt", "wt");
	FILE *fp_m_y = fopen("Bspline_test_y.txt", "wt");
	for (int i = 0; i < num2; i++){
		fprintf(fp_m_x, "%lf\n", testpt[i].x);
		fprintf(fp_m_y, "%lf\n", testpt[i].y);
	}
	fclose(fp_m_x);
	fclose(fp_m_y);
 
	return 0;
}